package com.wfuhui.modules.hospital.api;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.common.annotation.AuthIgnore;
import com.wfuhui.common.utils.R;
import com.wfuhui.modules.hospital.entity.PaymentEntity;
import com.wfuhui.modules.hospital.service.PaymentService;

/**
 * 缴费记录
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/api/payment/")
public class ApiPaymentController {
	
	@Autowired
	private PaymentService paymentService;
	
	@AuthIgnore
    @GetMapping("list")
    public R list(@RequestParam Map<String, Object> params) {
    	List<PaymentEntity> paymentList = paymentService.queryList(params);
    	return R.ok().put("paymentList", paymentList);
    }
	
	@GetMapping("mylist")
    public R mylist(@RequestParam Map<String, Object> params, @RequestAttribute Long userId) {
		params.put("userId", userId);
    	List<PaymentEntity> paymentList = paymentService.queryList(params);
    	return R.ok().put("paymentList", paymentList);
    }
	
	@PostMapping("save")
    public R save(@RequestBody PaymentEntity payment, @RequestAttribute Long userId) {
		payment.setUserId(userId);
		payment.setCreateTime(new Date());
    	paymentService.save(payment);
    	return R.ok();
    }
}
